
//
//  UIImageView+WebImage.swift
//  VVbo
//
//  Created by Mr.Run on 2017/8/29.
//  Copyright © 2017年 Mr.Run. All rights reserved.
//

import SDWebImage

extension UIImageView {
    
    func vv_setImage(urlString: String?, placeholderImage:UIImage?, isAvatar:Bool = false) {
        
        guard let urlString = urlString,
        let url = URL(string:urlString) else {
            image = placeholderImage
            return
        }
        
        sd_setImage(with: url, placeholderImage: placeholderImage, options: []) {[weak self] (image, _, _, _) in
            if isAvatar {
                self?.image = image?.cz_avatarImage(size: self?.bounds.size)
            }
        }
    }
}


